ZGUID.DLL Version 1.0.0 Readme File

Introduction:
===================

The use of GUID (Global Unique ID) field can be a great ease in the database design. However, you must handle this type of value in your programs, for example, changing its value in a recordset, inserting a new value in an action query, or passing a parameter value in a selection query, etc. 

Now, you can rely on ZGUID ActiveX Component to do these jobs for you. 

ZGUID component can be used with DAO, RDO and ADO. 

Description:
=====================

**************************************************************************************
•	ActiveX Component for handling Microsoft Access 97 and SQL Server GUID fields 
•	SourceType: stACCESS, stMSSQL (Or 0, 1)

•	CreateGuid(ByVal st As SouceType): 

•	Create a new GUID value, 
•	st: 0 Access, 1: SQL Server.
•	
•	StringToGuid(ByVal sGUID As String, ByVal st As SourceType): 
•	
•	Convert a GUID string to a GUID value,
•	sGUID: a GUID String, for example, {A8EDCF10-1E23-11d2-A4F4-002018614C28},
•	st: 0 Access, 1: SQL Server.
•	
•	
•	GuidToString(ByVal g As Variant):
•	Convert a GUID value to a GUID string,
•	g: a GUID Value,
•	st: 0 Access, 1: SQL Server.
•	
•	Copyright © 1998 Benison Zane
•	

Database Field Format:
=========================

MS Access 97 GUID Field: Replication ID
MS SQL Server GUID field: binary (16)

Example uses for Visual Basic:
=========================

(1)	RDO Example:

Private Sub Command1_Click()

    On Error GoTo err_command1
    
    Dim id As Variant
    Dim qd As New rdoQuery
    Dim rs As rdoResultset

    id = ZGUID.CreateGuid(stMSSQL)			‘Create GUID value		

    With qd
        Set .ActiveConnection = Cnn				‘MS SQL Server Connection
        .SQL = "insert into table1 values (?, ?)"
        qd(0).Type = rdTypeBINARY				‘GUID Field Type
        qd(0).Value = id
        qd(1).Type = rdTypeINTEGER
        qd(1).Value =  1998
        qd.Execute
        .SQL = "select * from table1 where id = ?"
        qd(0).Type = rdTypeBINARY
        qd(0).Value = id
        Set rs = .OpenResultset(rdOpenKeyset)			‘rdoResultset
    End With
    
    Rs.MoveFirst
    Text1 = ZGUID.GuidToString(rs.rdoColumns(0).Value, stMSSQL)	‘Display new GUID String
   
exit_command1:
    If Err.Number <> 0 Then Err.Clear
    
    On Error Resume Next
    rs.Close
    Set rs = Nothing
    Set qd = Nothing

    Exit Sub
    
err_command1:
    MsgBox Err.Description
    GoTo exit_command1
    
End Sub

(2) ADO Example:

    Private Sub Command1_Click()
    
    On Error GoTo err_command1
    
    Dim id As Variant
    Dim rs As New adodb.Recordset
    Dim cmd As New adodb.Command
    Dim prm As adodb.Parameter
    
    id = ZGuid.CreateGuid(stMSSQL)
    
    Text1 = ZGuid.GuidToString(id, stMSSQL)
    
    With cmd
        .ActiveConnection = cnn
 
        .CommandText = "insert into table1 (id) values (?)"
        .CommandType = adCmdText
        
        Set prm = .CreateParameter(“idPrm”, adBinary, _
        adParamInput, 16, id)        
        .Parameters.Append prm
        
        .Execute
        
        .CommandText = "select * from table1"
        .CommandType = adCmdText
        
        .Parameters.Delete 0
        
        Set prm = .CreateParameter(“idPrm”, adBinary, _
        adParamInput, 16, ZGuid.StringToGuid(Text1, stMSSQL))        
        .Parameters.Append prm
        
        Set rs = .Execute
    End With
    
    rs.MoveFirst
    Text2 = ZGuid.GuidToString(rs.Fields(0).Value, stMSSQL)        
   
exit_command1:
    If Err.Number <> 0 Then Err.Clear
    
    On Error Resume Next
    rs.Close
    Set rs = Nothing
    cmd.Parameters.Delete 0
    Set cmd = Nothing
    
    Exit Sub
    
err_command1:
    MsgBox Err.Description
    GoTo exit_command1

End Sub

(3) DAO example:

Private Sub Command1_Click()

    On Error GoTo err_command4
    
    Dim db As dao.Database
    Dim rs As dao.Recordset
    Dim qd As dao.QueryDef
    Dim id As Variant    

    id = ZGUID.CreateGuid(stACCESS)
        
    Set db = OpenDatabase("example.mdb")
    Set qd = db.CreateQueryDef("")
        
    With qd
        .SQL = "PARAMETERS idPrm Binary; " & _
            "insert into table1 (id) values (idPrm);"
        .Parameters!idPrm = id
        .Execute
    
        .SQL = "PARAMETERS idPrm Binary; " & _
            "select * from table1 where id = idPrm;"
        .Parameters!idPrm = id
        
        Set rs = .OpenRecordset(dbOpenDynaset)
    End With
    
    rs.MoveFirst
    Text1 = rs!id			

exit_command1:
    If Err.Number <> 0 Then Err.Clear
    On Error Resume Next
    db.Close
    Exit Sub
    
err_command1:
    MsgBox Err.Description
    GoTo exit_command1
    
End Sub

Contact:
=================

Email: 	100774.3662@compuserve.com
WebPage: http://ourworld.compuserve.com/homepages/zbase/
Tel: 	+44 113 2 407 654

Shareware Registration Info:
==============================

Program Title: ZGUID ACTIVEX COMPONENT VERSION 1.0.0
Registration ID: 17222